//
//  CHQuestionViewController.m
//  CarFile
//
//  Created by 陈浩 on 2017/4/8.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHQuestionViewController.h"
#import "CHTextView.h"
@interface CHQuestionViewController ()<UITextViewDelegate>
@property (nonatomic ,strong) CHTextView *textView;
@end

@implementation CHQuestionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"意见反馈";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"n_bg"] forBarMetrics:0];

 
    
    CHTextView *textView = [[CHTextView alloc] initWithFrame:CGRectMake(18, 23, UIScreenW - 36, 240)];
    textView.layer.cornerRadius = 5;
    textView.layer.masksToBounds = YES;
    textView.layer.borderWidth = 1;
    textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    textView.placeholder = @"请输入您的问题...";
    textView.delegate = self;
    [self.view addSubview:textView];
    self.textView = textView;
    
    
    
    UIButton *submitBtn = [[UIButton alloc] initWithFrame:CGRectMake(18, CGRectGetMaxY(textView.frame)+20, UIScreenW - 36, 40)];
    submitBtn.layer.cornerRadius = 5;
    submitBtn.layer.masksToBounds = YES;
    submitBtn.backgroundColor =  [UIColor colorWithHexString:@"148ec7" alpha:1.0f];
    submitBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [submitBtn setTitle:@"提交" forState:UIControlStateNormal];
    [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [submitBtn addTarget:self action:@selector(submitBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:submitBtn];
    
    
}


-(void)submitBtnClick{
    
    
    NSLog(@"提交");
    
    
}





-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    [self.textView becomeFirstResponder];
}


#pragma mark - <UITextViewDelegate>
-(void)textViewDidChange:(UITextView *)textView
{
    self.navigationItem.rightBarButtonItem.enabled = textView.hasText;
}

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
}

@end
